package mission

import (
	"gqlgen-test2/db"
	"math/rand"
	"strconv"
)

func addLocation(c chan bool) {
	/*	var locations = make([]model.Location, 1000)
		for i := 0; i < 1000; i++ {
			locations[i] = model.Location{
				VehicleId:           getVehicleId(),
				Lat:                 getLat(),
				Lon:                 getLon(),
				LocationDescription: nil,
				Mileage:             nil,
				GPS_speed:           getSpeed(),
			}
		}
		db.DB.Model(&model.Location{}).Create(&locations)*/
	db.DB.Exec("INSERT INTO \"locations\" (\"created_at\",\"updated_at\",\"deleted_at\",\"vehicle_id\",\"lat\",\"lon\",\"location_description\",\"mileage\",\"gps_speed\") select now(), now(), null,vehicle_id,lat,lon,location_description,mileage,gps_speed from  locations where id >30000 limit 500000 ")
	<-c
}

func getVehicleId() *string {
	i := rand.Intn(50000)
	s := strconv.Itoa(i)
	return &s
}

func getLat() *float64 {
	f := rand.Float64()*20 + 120
	return &f
}
func getLon() *float64 {
	f := rand.Float64()*20 + 280
	return &f
}

func getSpeed() *float64 {
	f := rand.Float64()*80 + 60
	return &f
}
